/***************************************************************************
 *            obj_model.h
 *
 *  Sat Sep  6 20:52:43 2008
 *  Copyright  2008  Tiago Falcão
 *  <tiago@tiagofalcao.com>
 ****************************************************************************/

/*
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Library General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor Boston, MA 02110-1301,  USA
 */
 
#ifndef _OBJ_MODEL_H
#define OBJ_MODEL_H

#include <stdio.h>
#include <stdlib.h>
#include "points.h"
#include "object_3d.h"

#define OBJMODEL_MODE_WIRE 0x02
#define OBJMODEL_MODE_FILL 0x04
#define OBJMODEL_MODE_SMOOTH 0x08
#define OBJMODEL_MODE_FACE 0x10

typedef struct obj_model{
	GLfloat **v;				//Vertices  (matriz Nx3(+3 da normal do vertice))
	unsigned int v_size;		//Numero N de vertices
	GLfloat ***f;				//Faces     (matriz Nx3 de apontadores de Vertices)
	GLfloat **fn;				//Normais das Faces
	unsigned int f_size;		//Numero N de Faces
} obj_model;


//Carrega Estrutura de arquivo OBJ
obj_model * model_load(char * file);

//Deleta Estrutura
void model_delete(void * ptr);

//Display de Modelo de Malha Triangular
void model_display(void * model,unsigned int mode);

//Normaliza
void normalize(GLfloat v[3]);

//Normal
void normcrossprod(GLfloat v1[3], GLfloat v2[3], GLfloat out[3]);

//Determinante
GLfloat det(GLfloat v1[3],GLfloat v2[3],GLfloat v3[3]);

#endif

